package mortal.game.manager
{
	import com.gengine.global.*;
	import flash.display.*;
	import mortal.component.window.*;
	
	public class WindowLayer extends UILayer
	{
		
		public function WindowLayer()
		{
			
		}
		
		override public function centerPopup(param1:DisplayObject) : void
		{
			param1.x = (Global.stage.stageWidth - param1.width) / 2;
			param1.y = (Global.stage.stageHeight - param1.height) / 2;
			if (Global.stage.stageHeight - param1.height - 100 < param1.y)
			{
				param1.y = Global.stage.stageHeight - param1.height - 100;
			}
			if (Global.stage.stageWidth - param1.width - param1.x - 280 < 0)
			{
				param1.x = Global.stage.stageWidth - param1.width - 280;
			}
			if (param1.x < 0)
			{
				param1.x = 0;
			}
			if (param1.y < 0)
			{
				param1.y = 0;
			}
			
		}
		
		public function leftToChat(param1:DisplayObject) : void
		{
			if (!this.contains(param1))
			{
				
			}
			param1.x = 280;
			
		}
		
		public function rightToTask(param1:DisplayObject) : void
		{
			if (!this.contains(param1))
			{
				
			}
			param1.x = Global.stage.stageWidth - param1.width - 280;
			
		}
		
		public function centerWindows(... args) : void
		{
			var len:int = 0;
			var _loc_3:* = new Vector.<Window>;
			var _loc_4:int = 0;
			while (_loc_4 < args.length)
			{
				
				if (!args[_loc_4] is Window)
				{
				}
				else
				{
					_loc_3.push(args[_loc_4] as Window);
					args = args + (args[_loc_4] as Window).width;
				}
				_loc_4++;
			}
			len = len + (_loc_3.length - 1) * 5;
			var _loc_5:* = (Global.stage.stageWidth - len) / 2;
			var _loc_6:int = 0;
			while (_loc_6 < _loc_3.length)
			{
				
				_loc_3[_loc_6].show();
				_loc_3[_loc_6].x = _loc_5;
				_loc_5 = _loc_5 + (_loc_3[_loc_6].width + 5);
				_loc_6++;
			}
			
		}
		
	}
}
